package com.example.miniappssm.controller;

import com.example.miniappssm.bean.Camera;
import com.example.miniappssm.service.CameraService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@ResponseBody
public class CameraController {

    @Autowired
    CameraService cameraService;

    @RequestMapping("/showCamera")
    public Camera showCamera(@RequestParam("cameraId") Integer cameraId) {
        return cameraService.showCameraByCameraId(cameraId);
    }

    @RequestMapping("/showAllCamera")
    public List<Camera> showAllCamera() {
        return cameraService.showAllCamera();
    }

    @PostMapping("/addCamera")
    public void addCamera(Camera camera) {
        cameraService.addCamera(camera);
    }

    @PostMapping("/updateCamera")
    public void updateCamera(Camera camera) {
        cameraService.updateCamera(camera);
    }

    @RequestMapping("/removeCamera")
    public void removeCamera(@RequestParam("cameraId") Integer cameraId) {
        cameraService.removeCameraByCameraId(cameraId);
    }
}
